namespace DigitalCv.Data
{
    using System.IO;
    using System.Xaml;

    public class XamlSerializer
    {
        public string Serialize<TModel>(TModel model) where TModel : class
        {
            using (var writer = new StringWriter())
            {
                XamlServices.Save(writer, model);
                return writer.ToString();
            }
        }

        public TModel Deserialize<TModel>(string xaml) where TModel : class
        {            
            using (var reader = new StringReader(xaml))
            {
                var model = XamlServices.Load(reader) as TModel;
                return model;
            }
        }
    }
}